<template>
	<view>
		<view class="rulebox">
			<view style="text-align: center;">
				<view class="title">食尚霸王餐</view>
			</view>
			<!-- <view class="item flex-y-center" v-for="(item,index) in list" :key="index">
				<view class="num flex-grow-0">{{index+1}}</view>
				<view>{{item}}</view>
			</view> -->
			<div style="margin-top: 10px;">
				<u-parse :content="article" @preview="preview" @navigate="navigate" noData="正在加载中..." />
			</div>

			<button open-type="share" url="/pages/shareCode/shareCode" class="share-btn">分享赚钱</button>
		</view>
	</view>
</template>
<script>
	import uParse from '@/components/u-parse/parse.vue';

	import {
		revenueRule
	} from '../../apirequest/api.js';
	export default {
		components: {
			uParse
		},
		data() {
			return {
				article: ''
			}
		},
		onLoad() {
			this.loadData();
		},
		onShareAppMessage() {
			return {
				title: '食尚霸王餐',
				path: '/pages/index/newIndex',
			}
		},
		methods: {
			//获取数据
			loadData: function() {
				revenueRule({}).then((res) => {
					if (res.code == 1) {
						this.article = res.data;
					} else {
						uni.showToast({
							title: res.msg,
							icon: "error"
						})
						setTimeout(function() {
							uni.navigateBack({
								delta: 0
							});
						}, 1000)
					}
				}).catch(err => {
					console.log(err)
				})

			},
			preview(src, e) {
				// do something
				console.log(src);
				console.log(e)
			},
			navigate(href, e) {
				// do something
			}
		}
	}
</script>

<style>
	@import url("@/components/u-parse/parse.css");
</style>

<style>
	.rulebox {
		background: #fff;
		border-radius: 10rpx;
		margin: 60rpx 20rpx;
		padding: 0 25rpx 30rpx;

	}

	.rulebox .title {
		background: #f1922b;
		color: #fff;
		border-radius: 40rpx;
		padding: 20rpx 30rpx;
		margin: auto;
		display: initial;
		font-size: 26rpx;
		position: relative;
		top: -16rpx;

	}

	.rulebox .item {
		margin: 40rpx 0;
		font-size: 24rpx;
		color: #333;
	}

	.rulebox .item .num {
		background: #FDD223;
		font-weight: 700;
		border-radius: 50%;
		text-align: center;
		width: 40rpx;
		height: 40rpx;
		line-height: 40rpx;
		margin-right: 15rpx;
		font-size: 20rpx;
	}

	.rulebox .share-btn {
		background: linear-gradient(to right, #ffae31, #fe771d);
		text-align: center;
		color: #fff;
		padding:  0;
		font-size: 39rox;
		border-radius: 40rpx;
		margin: 50rpx 20rpx 0;
	}
</style>